package main

import (
	"fmt"
	"net"
	"net/rpc"
	"net/rpc/jsonrpc"
)

type Test struct{}

func (t *Test)Add(num map[string]int,resp *int) error{
	*resp=num["a"]+num["b"]
	return nil
}
func main(){

	rpc.RegisterName("beifeng",new(Test))
	Listener, error:=net.Listen("tcp","0.0.0.0:9501")

	if error!=nil{
		fmt.Printf("listen error")
		return
	}
	defer Listener.Close()
	for {

		Conn, error:=Listener.Accept()

		if error!=nil{
			fmt.Printf("acceot error")
		}else{
			go jsonrpc.ServeConn(Conn)
		}
	}


}
